package com.ourcraft.informationcollectionsystem.controller.province;



import com.alibaba.fastjson.JSONObject;
import com.ourcraft.informationcollectionsystem.entity.InvestigationPeriod;
import com.ourcraft.informationcollectionsystem.service.province.investigationManage.InvestigationManageService;
import com.ourcraft.informationcollectionsystem.utils.response.Result;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ourcraft.informationcollectionsystem.entity.Company;
import com.ourcraft.informationcollectionsystem.service.province.filingInfoQuery.FilingInfoQueryService;
import com.ourcraft.informationcollectionsystem.entity.DTO.DataReportFormDTO;
import com.ourcraft.informationcollectionsystem.service.province.formQuery.FormQueryService;

import java.util.List;


@RequestMapping("province/dataVisualization/")
@RestController
@CrossOrigin()
public class DataVisualizationController {
    @Autowired
    private InvestigationManageService investigationManageService;
    @Autowired
    FilingInfoQueryService filingInfoQueryService;
    @Autowired
    FormQueryService formQueryService;

    @GetMapping("allInvestigationInfo")
    public Result<List<InvestigationPeriod>> getAllInvestigationInfo(HttpServletRequest request) {
        return Result.success(investigationManageService.getAllInvestigationInfo());
    }

    @PostMapping("getRequiredFilingInfoList")
    public Result<List<Company>> getRequiredFormList(@RequestBody JSONObject param){
        var formQuery = filingInfoQueryService.getRequiredFilingInfoList(param);
        return Result.success(formQuery);
    }

    @PostMapping("getRequiredFormListJoin")
    public Result<List<DataReportFormDTO>> getRequiredFormListJoin(@RequestBody JSONObject param){
        var formQuery = formQueryService.getRequiredFormListJoin(
                param.getJSONObject("company"),
                param.getJSONObject("investigationPeriod")
        );
        return Result.success(formQuery);
    }

}
